package calvin.study.springboot.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import calvin.study.springboot.dao.LogDao;

@Service
public class ProductLogService {

	@Autowired
	private LogDao logDao;
	
	
	@Transactional(propagation=Propagation.REQUIRED)
	public void insertLog01(Long bizId,int optType,String json) {
		this.insert(bizId, optType, json);
	}
	
	@Transactional(propagation=Propagation.REQUIRED)
	public void insertLog02(Long bizId,int optType,String json) {
		this.insert(bizId, optType, json);
		throw new RuntimeException();
	}
	
	public void insertLog03(Long bizId,int optType,String json) {
		this.insert(bizId, optType, json);
	}
	
	@Transactional(propagation=Propagation.REQUIRES_NEW)
	public void insertLog04(Long bizId,int optType,String json) {
		this.insert(bizId, optType, json);
	}
	
	
	@Transactional(propagation=Propagation.NESTED)
	public void insertLog05(Long bizId,int optType,String json) {
		this.insert(bizId, optType, json);
		throw new RuntimeException();
	}
	
	
	@Transactional
	public void insertLog06(Long bizId,int optType,String json) {
		this.insert(bizId, optType, json);
	}


	private void insert(Long bizId,int optType,String json) {
		logDao.insert(bizId, optType, json);
	}
	

}
